USE [EstudiosComerciales]
GO
 -- creating the store procedure
IF EXISTS (SELECT name 
	   FROM   sysobjects 
	   WHERE  name = 'WASP_D0002_TRUNCATE_TABLE_FLAG_PD'
	   AND 	  type = 'P')
    DROP PROCEDURE [dbo].[WASP_D0002_TRUNCATE_TABLE_FLAG_PD]
GO
CREATE PROCEDURE [dbo].[WASP_D0002_TRUNCATE_TABLE_FLAG_PD]
AS

DECLARE @CRFECAPROB INT 
SELECT @CRFECAPROB = MAX (CRFECAPROB) 
FROM SQL.CSOPF000 
UPDATE [SQL].[FLAG_PD] SET FLAG = FLAG + 1, FECHA =@CRFECAPROB , CDATE = GETDATE()